package com.lm.pagehelper.service;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.lm.pagehelper.entry.SysUserEntity;
import com.lm.pagehelper.mapper.SysUserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class UserService extends ServiceImpl<SysUserMapper, SysUserEntity> {

    @Resource
    private SysUserMapper sysUserMapper;

    public SysUserEntity getUserById(Long id){
        return sysUserMapper.selectById(id);
    }

    public PageInfo<SysUserEntity> getUsers(int pageNum, int pageSize) {
        // 开启分页
        PageHelper.startPage(pageNum, pageSize);
        List<SysUserEntity> users = sysUserMapper.findAll();
        return new PageInfo<>(users);
    }
}